HackerRank Hackerland Radio Transmitters
提出
code: python
import math
import os
import random
import re
import sys
import bisect
#
# Complete the 'hackerlandRadioTransmitters' function below.
#
# The function is expected to return an INTEGER.
# The function accepts following parameters:
# 1. INTEGER_ARRAY x
# 2. INTEGER k
#
def hackerlandRadioTransmitters(x, k):
# Write your code here
x.sort()
i, ans = 0, 0
while (i < n):
i += 1
while (i < n and xi <= s + k): i += 1
while (i < n and xi <= p + k): i += 1
ans += 1
return ans
if __name__ == '__main__':
first_multiple_input = input().rstrip().split()
n = int(first_multiple_input0) k = int(first_multiple_input1) x = list(map(int, input().rstrip().split()))
result = hackerlandRadioTransmitters(x, k)
fptr.write(str(result) + '\n')
fptr.close()
メモ